import request from "@/utils/request.ts";
import {
  OrderInfoResponseData, OrderStatusResponseData,
  PayResultResponseData,
  QrCode,
  SubmitOrderResponseData,
  UserInfoResponseData, UserOrderResponseData, UserParams
} from "@/api/user/type.ts";
import {ResponseData} from "@/api/home/type.ts";

enum API{
  SUBMIT_ORDER_URL = '/order/orderInfo/auth/submitOrder/',
  GET_ORDER_INFO_URL = '/order/orderInfo/auth/getOrderInfo/',
  CANCEL_ORDER_URL = '/order/orderInfo/auth/cancelOrder/',
  QRCODE_URL = '/order/weixin/createNative/',
  PAY_RESULT_URL = '/order/weixin/queryPayStatus/',
  GET_USER_INFO_URL = '/user/auth/getUserInfo',
  USER_AUTH_URL = '/user/auth/userAuah',
  USER_ORDER_LIMIT_URL = '/order/orderInfo/auth/',
  GET_ORDER_STATUS_URL = '/order/orderInfo/auth/getStatusList',
  DELETE_PATIENT_URL = '/user/patient/auth/remove/'
}

/**
 * ### 提交预约
 * @param hoscode
 * @param scheduleld
 * @param patientId
 */
export const reqSubmitOrder = (hoscode:string,scheduleld:string,patientId:string)=>{
  return request.post<any,SubmitOrderResponseData>(API.SUBMIT_ORDER_URL+`${hoscode}/${scheduleld}/${patientId}`)
}
/**
 * ### 获取预约详情
 * @param orderId
 */
export const reqOrderInfo = (orderId:string)=>{
  return request.get<any,OrderInfoResponseData>(API.GET_ORDER_INFO_URL+orderId);
}
/**
 * ### 取消预约
 * @param orderId
 */
export const reqCancelOrder = (orderId:string)=>{
  return request.get<any,ResponseData>(API.CANCEL_ORDER_URL+orderId);
}
/**
 * ### 获取支付二维码
 * @param orderId
 */
export const reqQrcode = (orderId:string)=>{
  return request.get<any,QrCode>(API.QRCODE_URL+orderId);
}

/**
 * ### 查询订单支付状态
 * @param orderId
 */
export const reqPayResult = (orderId:string)=>{
  return request.get<any,PayResultResponseData>(API.PAY_RESULT_URL+orderId);
}
/**
 * ### 获取用户认证信息
 */
export const reqUserInfo = ()=>{
  return request.get<any,UserInfoResponseData>(API.GET_USER_INFO_URL);
}
/**
 * ### 提交用户认证信息
 * @param data
 */
export const reqUserAuth = (data:UserParams)=>{
  return request.post<any,ResponseData>(API.USER_AUTH_URL,data);
}
/**
 * ### 获取用户订单列表
 * @param pageNo
 * @param pageSize
 * @param patientId
 * @param orderStatus
 */
export const reqUserOrderLimit = (pageNo:number,pageSize:number,patientId:string,orderStatus:string)=>{
  return request.get<any,UserOrderResponseData>(API.USER_ORDER_LIMIT_URL+`${pageNo}/${pageSize}?patientId=${patientId}&orderStatus=${orderStatus}`);
}
/**
 * ### 获取订单状态列表
 *
 */
export const reqGetOrderStatus = ()=>{
  return request.get<any,OrderStatusResponseData>(API.GET_ORDER_STATUS_URL);
}
/**
 * ### 删除就诊人
 * @param id
 */
export const reqDeletePatient = (id:string)=>{
  return request.delete<any,ResponseData>(API.DELETE_PATIENT_URL+id);
}
